package handler

import (
	"github.com/gin-gonic/gin"
	"repo-man/model"
)

func RepoAdd(c *gin.Context) {
	repoStyle := c.PostForm("repoStyle")
	repoName := c.PostForm("repoName")
	repo := c.PostForm("repo")
	data := model.Repo{
		RepoStyle: repoStyle,
		RepoName:  repoName,
		Repo:      repo,
	}
	err := model.DB.Create(&data).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 400,
			"msg":  "添加失败",
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
		"data": data,
	})
	return
}
